using UnityEngine;
using UnityEngine.UI;

public class ShopSystem : MonoBehaviour
{
    public Player player;
    public GameObject messageBox;
    public Text messageText; // 使用Text代替TMP_Text
    private int _playerCurrency;

    public int PlayerCurrency
    {
        get => _playerCurrency;
        set
        {
            _playerCurrency = value;
            player.gold = value;
            UpdateCurrencyDisplay();
        }
    }

    private void Start()
    {
        if (player == null)
        {
            Debug.LogError("Player没有挂载");
            return;
        }

        PlayerCurrency = player.gold;
    }

    public void UpdateCurrencyDisplay()
    {
        //playerCurrencyText.text = $"金币: {PlayerCurrency}";
    }

    public void ShowMessage(string message)
    {
        messageBox.SetActive(true);
        messageText.text = message;
        Invoke(nameof(HideMessage), 2);
    }

    private void HideMessage()
    {
        messageBox.SetActive(false);
    }
}